<html>
<head>
	<meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control " content="no-cache,must-revalidate">
    <meta name="description" content="">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="webapp/images/favicon.ico">
	<link rel="icon" href="webapp/images/favicon.ico">
	<title>广东正诚电器科技有限公司</title>
	<link type="text/css" rel="stylesheet" href="webapp/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="webapp/style.css">

	<script type="text/javascript" src="webapp/jQuery/jquery.min.js"></script>

    <script type="text/javascript" src="webapp/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="content" style="height:420px;">
			<h1 style="font-weight: bold;font-size: 40px;">用户登录</h1>
			<form method="post">

                <div class="input-group input-group-lg" style="margin-bottom:30px;margin-top:30px;margin-left: 80px;">
                    <span class="input-group-addon" id="sizing-addon"><span class="glyphicon glyphicon-user" aria-hidden="true" style="color: black">　账号　</span></span>
                    <input type="text" class="form-control" placeholder="Username" id="account" aria-describedby="sizing-addon" autofocus style="width: 400px;">
                </div>

                <div class="input-group input-group-lg" style="margin-bottom:30px;margin-left: 80px;">
                    <span class="input-group-addon" id="sizing-addon1"><span class="glyphicon glyphicon-lock" aria-hidden="true" style="color: black">　密码　</span></span>
                    <input type="password" class="form-control"  placeholder="Password" id="password" aria-describedby="sizing-addon1" style="width: 400px;">
                </div>

                <div class="form-group" style="margin-bottom:235px;">

                <input type="button" class="btn btn-info btn-block" id="btn_login" style="width:200px;margin:0 auto;font-size: 20px;" value="登陆">

                </div>
            </form>
            <div style="margin-top: -205px;font-size: 30px;margin-left: 15px;width: 300px;">
                <label style="color:white;">第三方登录：<a href="/login/dgut" ><img src="webapp/images/dgut.png" style="width: 50px; height: 50px;" alt="莞工登陆"></a></label>
            </div>
            <div style="font-size: 20px;width: 200px;margin-left: 480px;margin-top: -60px;">
                <label style="color:white;">新客户，<a href="webapp/register.html" style="font-size: 30px;color:white;">立即注册</a></label>
            </div>
		</div>
	</div>
</body>
</html>

<script>
    $(function () {
        $("#btn_login").click(function () {
            var account = document.getElementById("account");
            var password = document.getElementById("password");
            var flag = 1;
            if (account.value == "") {
                alert("用户名不能为空!");
                flag = 0;
            }
            else {
                if (password.value == "") {
                    alert("密码不能为空!");
                    flag = 0;
                }
                if (flag == 1) {
                    $.get(
                        "/LoginCheckServlet",
                        {account:account.value, password:password.value},
                        function (data) {
                            var exit = data.exit;
                            if (exit == 0) {
                                alert("该账号不存在");
                            }
                            else if(exit == 2){
                                alert("密码错误");
                            }
                            else {
                                alert("登陆成功，点击确认后前往用户页面");
                                window.location.href = "webapp/index.jsp";
                            }
                        }
                    );
                }
            }
        });
    });
</script>